package com.serviceprovider.business.module.user.model.impl;

//~--- non-JDK imports --------------------------------------------------------

import com.serviceprovider.business.module.admin.address.model.Address;
import com.serviceprovider.business.module.admin.role.model.Role;
import com.serviceprovider.business.module.admin.user.model.Saveable;

import org.apache.commons.lang.StringUtils;

//~--- JDK imports ------------------------------------------------------------

import java.util.Date;

public class User extends Saveable implements Comparable<User> {

    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = -4414439620242687355L;
    private Role              role             = new Role();
    private String            alternateEmail;
    private int               bonusTestAmount;
    private Address           businessAddress;
    private String            businessFein;
    private String            businessName;
    private Integer           checkPrintingBy;
    private String            confirmPassword;    // for ui compatibility
    private Address           contactAddress;
    private Date              createdOn;
    private boolean           deleted;
    private Integer           efin;
    private String            email;
    private boolean           enabled;
    private String            firstName;
    private Boolean           inGui;              // whether payee is present in transaction approval
    private String            lastName;
    private User              level1User;
    private String            milddleName;
    private Integer           orderApproval;
    private Integer           ownerSsn;
    private String            password;
    private int               prefMessageNotifyAlert;
    private int               prefMessageNotifyType;
    private Integer           ptin;
    private int               refererId;
    private Address           shippingAddress;
    private Integer           ssn;

    public User() {
        level1User = new User(null);
    }

    public User(User level1User) {
        this.level1User = level1User;
    }

    public Boolean getInGui() {
        return inGui;
    }

    public void setInGui(Boolean inGui) {
        this.inGui = inGui;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getAlternateEmail() {
        return alternateEmail;
    }

    public void setAlternateEmail(String alternateEmail) {
        this.alternateEmail = alternateEmail;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public boolean isDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public int getRefererId() {
        return refererId;
    }

    public void setRefererId(int refererId) {
        this.refererId = refererId;
    }

    public User getLevel1User() {
        return level1User;
    }

    public void setLevel1User(User level1User) {
        this.level1User = level1User;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getMilddleName() {
        return milddleName;
    }

    public void setMilddleName(String milddleName) {
        this.milddleName = milddleName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getFullName() {
        StringBuilder builder = new StringBuilder().append(this.firstName).append(" ");

        if (StringUtils.isNotEmpty(this.milddleName)) {
            builder.append(this.milddleName).append(" ");
        }

        builder.append(this.lastName);

        return builder.toString();
    }

    public Integer getEfin() {
        return efin;
    }

    public void setEfin(Integer efin) {
        this.efin = efin;
    }

    public Integer getSsn() {
        return ssn;
    }

    public void setSsn(Integer ssn) {
        this.ssn = ssn;
    }

    public Integer getPtin() {
        return ptin;
    }

    public void setPtin(Integer ptin) {
        this.ptin = ptin;
    }

    public Integer getOrderApproval() {
        return orderApproval;
    }

    public void setOrderApproval(Integer orderApproval) {
        this.orderApproval = orderApproval;
    }

    public Integer getCheckPrintingBy() {
        return checkPrintingBy;
    }

    public void setCheckPrintingBy(Integer checkPrintingBy) {
        this.checkPrintingBy = checkPrintingBy;
    }

    public String getBusinessName() {
        return businessName;
    }

    public void setBusinessName(String businessName) {
        this.businessName = businessName;
    }

    public Integer getOwnerSsn() {
        return ownerSsn;
    }

    public void setOwnerSsn(Integer ownerSsn) {
        this.ownerSsn = ownerSsn;
    }

    public Address getContactAddress() {
        return contactAddress;
    }

    public void setContactAddress(Address contactAddress) {
        this.contactAddress = contactAddress;
    }

    public Address getBusinessAddress() {
        return businessAddress;
    }

    public void setBusinessAddress(Address businessAddress) {
        this.businessAddress = businessAddress;
    }

    public Address getShippingAddress() {
        return shippingAddress;
    }

    public void setShippingAddress(Address shippingAddress) {
        this.shippingAddress = shippingAddress;
    }

    public int getPrefMessageNotifyType() {
        return prefMessageNotifyType;
    }

    public void setPrefMessageNotifyType(int prefMessageNotifyType) {
        this.prefMessageNotifyType = prefMessageNotifyType;
    }

    public int getPrefMessageNotifyAlert() {
        return prefMessageNotifyAlert;
    }

    public void setPrefMessageNotifyAlert(int prefMessageNotifyAlert) {
        this.prefMessageNotifyAlert = prefMessageNotifyAlert;
    }

    public int getBonusTestAmount() {
        return bonusTestAmount;
    }

    public void setBonusTestAmount(int bonusTestAmount) {
        this.bonusTestAmount = bonusTestAmount;
    }

    public Date getCreatedOn() {
        return createdOn;
    }

    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }

    public String getConfirmPassword() {
        return confirmPassword;
    }

    public void setConfirmPassword(String confirmPassword) {
        this.confirmPassword = confirmPassword;
    }

    public String getBusinessFein() {
        return businessFein;
    }

    public void setBusinessFein(String businessFein) {
        this.businessFein = businessFein;
    }

    @Override
    public boolean equals(Object obj) {
        if ((obj == null) ||!(obj instanceof User)) {
            return false;
        }

        User b = (User) obj;

        return ((id == null) && (b.id == null)) || ((id != null) && id.equals(b.id));
    }

    @Override
    public int hashCode() {
        return (id != null)
               ? id.hashCode()
               : 0;
    }

    @Override
    public int compareTo(User o) {
        return this.firstName.compareTo(o.firstName);
    }
}



